// pages/ownerlist/ownerlist.js
const host = require('../../config.js').host;
const network = require('../../utils/network.js');
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		host: host,
		page: 1,
		loadFlg: true,
		limit: 10,
		list: []
	},
	bundling(e) {
		let customerRelationId = e.currentTarget.dataset.customerrelationid;
		let ownerId = e.currentTarget.dataset.ownerid;
		wx.navigateTo({
			url: '/pages/owner/owner?ownerId=' + ownerId + "&customerRelationId=" + customerRelationId + "&type=0"
		})
	},

	/**
	 * 获取业主申请列表
	 */
	getList() {
		var page = this.data.page;
		var limit = this.data.limit;
		var loadFlg = this.data.loadFlg;
		if (loadFlg) {
			network.requestGet('/xcx/customer-relation/merchant-owner-list', {
				"pageNum": page,
				"pageSize": limit,
				"relationType": 0,
				"isPage": 1,
				"isBinding": 0
			}, res => {
				console.log("res", res)
				let list = res.data.rows;
				if (list.length > 0) {
					this.setData({
						list: this.data.list.concat(list),
						page: page + 1
					})
				} else {
					this.setData({
						loadFlg: false
					})
				}
			})
		}
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {

	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {
		this.setData({
			loadFlg: true,
			page: 1,
			list: []
		})
		this.getList();
	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {
		this.getList();
	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	}
})
